﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace VLog
{
    internal class LogCommons
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns>返回默认的txt地址</returns>
        public static string GetPath()
        {
            return GetPath(LogType.TxtVLog);
        }

        /// <summary>
        /// 根据地址类型 获取实际地址 或是 数据库连接字符串
        /// </summary>
        /// <param name="pathType">地址类型PathType</param>
        /// <returns>返回 实际地址 或是 数据库连接字符串</returns>
        public static string GetPath(LogType pathType)
        {
            switch (pathType)
            {
                case LogType.XmlVLog:
                    return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "vlog.xml");
                case LogType.TxtVLog:
                    return string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "vlog.txt");
                case LogType.SqlVLog:
                    return
                        string.IsNullOrEmpty(
                            ConfigurationManager.ConnectionStrings["VLogConnectionString"].ConnectionString
                        )
                        ?
                        "server=.;user id=sa;password=;Pooling=true;"
                        :
                        ConfigurationManager.ConnectionStrings["VLogConnectionString"].ConnectionString;
                default:
                    return "windows日志（网站日志）";
            }
        }

    }
}
